import request from '@/utils/request'

// 查询基本信息列表
export function listTable(query) {
  return request({
    url: '/db/table/list',
    method: 'get',
    params: query
  })
}

// 查询基本信息详细
export function getTable(tableId) {
  return request({
    url: '/db/table/' + tableId,
    method: 'get'
  })
}

// 新增基本信息
export function addTable(data) {
  return request({
    url: '/db/table',
    method: 'post',
    data: data
  })
}

// 修改基本信息
export function updateTable(data) {
  return request({
    url: '/db/table',
    method: 'put',
    data: data
  })
}

// 删除基本信息
export function delTable(tableId) {
  return request({
    url: '/db/table/' + tableId,
    method: 'delete'
  })
}

// 导出基本信息
export function exportTable(query) {
  return request({
    url: '/db/table/export',
    method: 'get',
    params: query
  })
}

export function tableOptions(query) {
  return request({
    url: '/db/table/tableOptions',
    method: 'get',
    params: query
  })
}

export function uploadData(formData) {
  return request({
    url: '/db/table/uploadData',
    method: 'post',
    data: formData
  })
}


export function queryData(query, page, formData) {
  return request({
    url: '/db/table/queryData',
    method: 'get',
    params: {
      ...page,
      ...query,
      ...formData
    }
  })
}

export function removeRowEvent(tableId, _rowid) {
  return request({
    url: '/db/table/removeRowEvent/' + tableId + '/' + _rowid,
    method: 'post'
  })
}

export function uploadFileEvent(formData) {
  return request({
    url: '/db/table/uploadFileEvent',
    method: 'post',
    data: formData
  })
}

export  function getFileInfo(fileId) {
  return  request({
    url: '/db/table/getFileInfo/' + fileId,
    method: 'get'
  })
}

export  function getHistory(form) {
  return  request({
    url: '/db/table/getTableBatchUploadLogInfo',
    method: 'get',
    params: {      
      ...form
    }
  })
}

export  function getUploadDetail(batchId) {
  return  request({
    url: '/db/table/getTableBatchUploadLogDetail/' + batchId,
    method: 'get',
  })
}

export  function removeLog(logId) {
  return  request({
    url: '/db/table/removeLog/' + logId,
    method: 'delete',
  })
}

export  function restocking(logId) {
  return  request({
    url: '/db/table/restocking/' + logId,
    method: 'post',
  })
}